package com.jinbo.sxzq;

import android.util.Log;

/*********关卡信息类***************/
public class LevelMessage {
    private int level;//关卡编号
    private String levelname;//关卡名称
    private int[][] levelmessage;//关卡信息
    private int[][] levelowner;

    LevelMessage(int level, String levelname){
        this.level = level;
        this.levelname = levelname;
        this.levelowner = new int[ProjectConstants.BoardAttributes.LENGTH][ProjectConstants.BoardAttributes.WIDTH];
        this.levelmessage = initlevelmessage(level);
    }

    LevelMessage(int level){
        this(level,"-关卡名-");
    }

    public int[][] initlevelmessage(int level){
            int[][] levelmessage = new int[ProjectConstants.BoardAttributes.LENGTH][ProjectConstants.BoardAttributes.WIDTH];
            int[][] level_x;
            switch (level){
                case 1:
                    level_x = ProjectConstants.GameLevel.level_1;
                    break;
                case 2:
                    level_x = ProjectConstants.GameLevel.level_2;
                    break;
                case 3:
                    level_x = ProjectConstants.GameLevel.level_3;
                    break;
                case 4:
                    level_x = ProjectConstants.GameLevel.level_4;
                    break;
                case 5:
                    level_x = ProjectConstants.GameLevel.level_5;
                    break;
                case 6:
                    level_x = ProjectConstants.GameLevel.level_6;
                    break;
                case 7:
                    level_x = ProjectConstants.GameLevel.level_7;
                    break;
                case 8:
                    level_x = ProjectConstants.GameLevel.level_8;
                    break;
                case 9:
                    level_x = ProjectConstants.GameLevel.level_9;
                    break;
                case 10:
                    level_x = ProjectConstants.GameLevel.level_10;
                    break;
                case 11:
                    level_x = ProjectConstants.GameLevel.level_10;
                    break;
                case 12:
                    level_x = ProjectConstants.GameLevel.level_10;
                    break;
                default: level_x = null;
            }
            if(level_x != null){
                for(int i = 0 ; i < level_x.length ; i++){
                    levelmessage[level_x[i][0]][level_x[i][1]] = level_x[i][2];
                    this.levelowner[level_x[i][0]][level_x[i][1]] = ProjectConstants.ChessOwner.ENEMY;
                }
            }else{
                Log.e("LevelMessage","关卡信息初始化失败");
            }
            return levelmessage;
    }

    public int[][] getLevelmessage(){
            if(this.levelmessage != null){
                return this.levelmessage;
            }else{
                return initlevelmessage(this.level);
            }
    }

    public int[][] getLevelowner() {
            return this.levelowner;
    }
}
